//
//  Constant+ShowImage.swift
//  ImagePicker
//
//  Created by Lj on 2019/10/5.
//  Copyright © 2019 Less. All rights reserved.
//

import UIKit

struct LConstant { }

extension NSObject {
    
    class var l_nameOfClass: String {
        return NSStringFromClass(self).components(separatedBy: ".").last! as String
    }
    
    // 用于获取cell的reuse identifire
    class var l_identifire: String {
        return String(format: "%@_identifire", self.l_nameOfClass)
    }
}

extension Bundle {
    static func imagePickerBundle() -> Bundle? {
        let path = Bundle(for: ShowImageViewController.self).path(forResource: "ImagePicker", ofType: "bundle")
        let bundle = Bundle(path: path ?? "")
        return bundle
    }
}

extension UIDevice {
    /** iPhoneX、iPhone11Pro */
    public static var l_isIphoneX: Bool {
        return LConstant.screenHeight * UIScreen.main.scale == 2436 ? true : false
    }
    /** iPhoneXS MAX、iPhone11 Pro MAX */
    public static var l_isIphoneXM: Bool {
        return LConstant.screenHeight * UIScreen.main.scale == 2688 ? true : false
    }
    /** iPhoneXR、iPhone11 */
    public static var l_isIphoneXR: Bool {
        return LConstant.screenHeight * UIScreen.main.scale == 1792 ? true : false
    }
    /** 是否带刘海 */
    public static var l_isIphone_X: Bool {
        return (l_isIphoneX || l_isIphoneXM || l_isIphoneXR) ? true : false
    }
}


extension LConstant {
    /** 屏幕宽度 */
    public static var screenWidth: CGFloat {
        return UIScreen.main.bounds.size.width
    }
    /** 屏幕高度 */
    public static var screenHeight: CGFloat {
        return UIScreen.main.bounds.size.height
    }
    /** 状态栏高度 */
    public static var statusHeight: CGFloat {
        return UIApplication.shared.statusBarFrame.height
    }
    /** navtiveTitleView高度 */
    public static var topBarHeight: CGFloat {
        return 44.0
    }
    /** 头部高度 */
    public static var navbarAndStatusBar: CGFloat {
        return (statusHeight + topBarHeight)
    }
    /** 标签栏 */
    public static var bottomBarHeight: CGFloat {
        return UIDevice.l_isIphone_X ? 83.0 : 49.0
    }
    
    /** 比例 */
    public static var sizeScale: CGFloat {
        return screenWidth > 320 ? screenWidth/375.0 : 1
    }
}


